﻿/*版权声明
 * 
 * 本 WebName:IMIS_ERP 由
 * 河北大学 信管团队 开发
 * 如有任何疑问请联系开发人员
 * 
 * 项目开发者
 * 负责人：朱胜贤
 * 成员：水亚亚、孙旭峰、张文元、项玥、吕芳、吴凡、谢静、李亚慧
 *
 * 如有任何疑问请联系：河北大学信管团队
 * QQ：196396337
 * Email:zagelover@163.com
 * HomePage：http://sxgzs.com/
 *
 * CopyRight (c) 河北大学信管团队 2010~2020
 */

using System;
using System.Data;
using System.Collections.Generic;
using IMIS_ERP.Model;
namespace IMIS_ERP.BLL
{
    /// <summary>Manager_Info
    ///     <remarks>2011-03-07 河北大学信管团队</remarks>
    /// </summary>
    public class Manager_Info
    {
        private readonly IMIS_ERP.DAL.Manager_Info dal = new IMIS_ERP.DAL.Manager_Info();
        public Manager_Info()
        { }
        #region  Method

        /// <summary>是否存在该记录
        ///     <remarks>2011-03-07 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="miID">编号</param>
        /// <returns>返回是否存在</returns>
        public bool Exists(string miID)
        {
            return dal.Exists(miID);
        }

        /// <summary>管理人员是否存在
        /// 
        /// </summary>
        /// <param name="miID"></param>
        /// <param name="miPwd"></param>
        /// <returns>返回用户姓名</returns>
        public string Exists2(string miID, string miPwd)
        {
            return dal.Exists2(miID, Assistant.GetMD5(miPwd));
        }

        /// <summary>增加一条数据
        ///     <remarks>2011-03-07 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="model"></param>
        /// <returns>返回是否添加成功</returns>
        public bool Add(IMIS_ERP.Model.Manager_Info model)
        {
            model.miPwd = Assistant.AddToMD5(model.miPwd);
            return dal.Add(model);
        }

        /// <summary>更新一条数据
        ///     <remarks>2011-03-07 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="model"></param>
        /// <returns>返回是否修改成功</returns>
        public bool Update(IMIS_ERP.Model.Manager_Info model)
        {
            model.miPwd = Assistant.UpdateToMD5(model.miPwd);
            return dal.Update(model);
        }

        /// <summary>删除一条数据
        ///     <remarks>2011-03-07 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="miID">编号</param>
        /// <returns>返回是否删除成功</returns>
        public bool Delete(string miID)
        {

            return dal.Delete(miID);
        }

        /// <summary>批量删除记录
        ///     <remarks>2011-03-07 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="miIDlist">编号列表</param>
        /// <returns>返回删除的记录条数</returns>
        public int DeleteList(string miIDlist)
        {
            return dal.DeleteList(miIDlist);
        }

        /// <summary>得到一个对象实体
        ///     <remarks>2011-03-07 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="miID">编号</param>
        /// <returns>返回Model</returns>
        public IMIS_ERP.Model.Manager_Info GetModel(string miID)
        {

            return dal.GetModel(miID);
        }

        /// <summary>获得数据列表
        ///     <remarks>2011-03-07 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="strWhere">查询条件</param>
        /// <returns>返回DataSet</returns>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }

        /// <summary>获得前几行数据
        ///     <remarks>2011-03-07 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="Top">行数</param>
        /// <param name="strWhere">条件</param>
        /// <param name="filedOrder">排序</param>
        /// <returns>返回DataSet</returns>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>获得数据列表
        ///     <remarks>2011-03-07 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="strWhere">条件</param>
        /// <returns>返回List</returns>
        public List<IMIS_ERP.Model.Manager_Info> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }

        /// <summary>获得数据列表
        ///     <remarks>2011-03-07 河北大学信管团队</remarks>
        /// </summary>
        /// <param name="dt">DataTable</param>
        /// <returns>返回List</returns>
        public List<IMIS_ERP.Model.Manager_Info> DataTableToList(DataTable dt)
        {
            List<IMIS_ERP.Model.Manager_Info> modelList = new List<IMIS_ERP.Model.Manager_Info>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                IMIS_ERP.Model.Manager_Info model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new IMIS_ERP.Model.Manager_Info();
                    model.miID = dt.Rows[n]["miID"].ToString();
                    model.miRole = dt.Rows[n]["miRole"].ToString();
                    model.miProvince = dt.Rows[n]["miProvince"].ToString();
                    model.miCity = dt.Rows[n]["miCity"].ToString();
                    model.miName = dt.Rows[n]["miName"].ToString();
                    model.miPwd = dt.Rows[n]["miPwd"].ToString();
                    model.miPhone = dt.Rows[n]["miPhone"].ToString();
                    model.miInfo = dt.Rows[n]["miInfo"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>获得数据列表
        ///     <remarks>2011-03-07 河北大学信管团队</remarks>
        /// </summary>
        /// <returns>返回DataSet</returns>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 修改管理员密码
        /// </summary>
        /// <param name="huID"></param>
        /// <param name="huPwd"></param>
        /// <param name="huPwd1"></param>
        /// <returns></returns>
        public bool ChangePwd(string huID, string huPwd, string huPwd1)
        {
            return dal.ChangePwd(huID.ToLower(), Assistant.UpdateToMD5(huPwd), Assistant.UpdateToMD5(huPwd1));

        }

        #endregion  Method
    }
}

